package com.kharthick.pwGame.rules;

import java.util.List;

import com.kharthick.pwGame.map.Map;
import com.kharthick.pwGame.players.Player;
import com.kharthick.pwGame.units.Unit;

public class MoveRules implements Rules {
	public final int TILE_SIZE = 50;
	int row, col;
	Unit selectedUnit;
	int targetX;
	int targetY;
	
	public boolean actionOk(Unit u, int x, int y, List<Player> players) {
		//System.out.println("checking if ok");
		selectedUnit = u;
		row = x/TILE_SIZE;
		col = y/TILE_SIZE;
		
		boolean inRange = YesNo.inRange(u.getPosition(), row, col, u.getMovement());
		if(!inRange){
			//System.out.println("is not in range");
			return false;
		}
		//System.out.println("is in range");
		boolean empty = YesNo.empty(x, y, players);
		if (!empty){
			return false;
		}
		return true;
	}
	
	public void doAction(Map m) {
		selectedUnit.activateMove(row,col);
	}
}
